package com.mashibing.controller;

import com.mashibing.dto.ResponseResult;
import com.mashibing.request.VerificationCodeCheck;
import com.mashibing.request.VerificationCodeRequest;
import com.mashibing.responsse.NumberCodeResponse;
import com.mashibing.service.VerificationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PsVerificationCodeController {

    @Autowired
    private VerificationCodeService verificationCodeService;

    /**
     * 乘客获取验证码
     * @param verificationCodeRequest
     * @return
     */
    @GetMapping("/verification-code")
    public ResponseResult<NumberCodeResponse> sendVerificationCode (@RequestBody VerificationCodeRequest verificationCodeRequest){
        String phone = verificationCodeRequest.getPassengerPhone();
        ResponseResult<NumberCodeResponse> result = verificationCodeService.generateVerificationCode(phone);
        return result;
    }

    /**
     * 乘客校验验证码
     */
    @PostMapping("/verification-code-check")
    public ResponseResult checkVerificationCode(@RequestBody VerificationCodeCheck verificationCodeCheck){
        ResponseResult result = verificationCodeService.checkVerificationCode(verificationCodeCheck);
        return result;
    }



}
